export function getBarOptions(data) {
  const SCCountData = [];
  const KCCountData = [];
  const xAxisData = [];
  data.forEach(item => {
    SCCountData.push(item.total_count);
    KCCountData.push(item.finish_count);
    xAxisData.push(item.product_name);
  });
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow',
        label: {
          show: true,
        },
      },
    },
    toolbox: {
      show: false,
      feature: {
        mark: { show: true },
        dataView: { show: true, readOnly: false },
        magicType: { show: true, type: ['line', 'bar'] },
        restore: { show: true },
        saveAsImage: { show: true },
      },
    },
    calculable: true,
    legend: {
      data: ['Growth', 'Budget 2011', 'Budget 2012'],
      itemGap: 5,
    },
    grid: {
      top: '12%',
      left: '2%',
      right: '10%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'category',
        data: xAxisData,
      },
    ],
    yAxis: [
      {
        type: 'value',
        name: '产品数量汇总',
        // axisLabel: {
        //   formatter: function(a) {
        //     a = +a;
        //     return isFinite(a) ? echarts.format.addCommas(+a / 1000) : '';
        //   },
        // },
      },
    ],
    dataZoom: [
      {
        type: 'inside',
      },
    ],
    series: [
      {
        name: '生产总数量',
        type: 'bar',
        data: SCCountData,
        label: {
          show: true,
        },
      },
      {
        name: '库存数量',
        type: 'bar',
        data: KCCountData,
        label: {
          show: true,
        },
      },
    ],
  };
}
